﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxTabControl;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using System.Configuration;
using System.Data;

public partial class SelectPage_CustomerPick : Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.Title = "Customer";
            Session["CustWhere"] = "1=0";
            btn_Sch_Click(null, null);
        }
        if (Session["CustWhere"] != null)
        {
            this.dsCust.FilterExpression = Session["CustWhere"].ToString();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }
    protected void btn_Sch_Click(object sender, EventArgs e)
    {
            string name = this.txt_Name.Text.Trim().ToUpper();
            string sql = @"SELECT CustId as Id,Code,Name,Address,Tel1,Fax1,Email1,Contact1,Latitude,Longitude FROM BoClient ";
            if (name.Length > 0)
            {
                sql += string.Format(" where  name LIKE '{0}%'", name);
            }
            //string sql = @"SELECT Customer.BAccountID Id, BAccount.AcctCD Code, BAccount.AcctName Name FROM Customer INNER JOIN BAccount ON Customer.BAccountID = BAccount.BAccountID";
            //if (name.Length > 0)
            //{
            //    sql += string.Format(" where  BAccount.AcctName LIKE '{0}%'", name);
            //}
            DataTable tab = Touchmax.Manager.ORManager.GetDataSet(sql).Tables[0];
            this.ASPxGridView1.DataSource = tab;
            this.ASPxGridView1.DataBind();
    }
 
}
